package com.vipboot.framework.web.autoconfig.i18n;

import jakarta.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

/**
 * 国际化配置
 */
@Slf4j
@AutoConfiguration(before = WebMvcAutoConfiguration.class)
@ConditionalOnWebApplication
@EnableConfigurationProperties(I18nProperties.class)
@ConditionalOnProperty(prefix = "web.i18n", name = "enabled", havingValue = "true")
public class I18nAutoConfig {

    @PostConstruct
    public void postConstruct() {
        log.info("初始化 I18nAutoConfig");
    }

    @Bean
    public I18nLocaleResolver i18nLocaleResolver() {
        return new I18nLocaleResolver();
    }

    /**
     * 国际化文件配置
     */
//    @Bean
//    @ConditionalOnMissingBean
//    public MessageSourceBeanPostProcessor messageSourceBeanPostProcessor() {
//        return new MessageSourceBeanPostProcessor();
//    }
}
